import java.io.*;
import java.io.ObjectInputStream.GetField;
import java.sql.*;
import java.util.*;
import Steps.Steps;

import Classes.*;
import Errors.*;
import Errors.Error;
import DAO.GenreDAO;
import DAO.VoorstellingDAO;
import DBConnection.ConnectionDB;



public class Main{


	public static void main(String[] args) throws ClassNotFoundException, FileNotFoundException, IOException {
	
		Connection databaseConnection = null;
		ResultSet resultSet= null;

		Scanner scanIn = new Scanner(System.in);
		
		try{
			
			/*Properties jdbcProperties = new Properties();
			FileInputStream fisProperty = new FileInputStream("conf/db.properties");
			jdbcProperties.load(fisProperty);
			String driver = jdbcProperties.getProperty("driver");
			String url = jdbcProperties.getProperty("url");
			
			String user = jdbcProperties.getProperty("user");
			String password = jdbcProperties.getProperty("password");
			Class.forName(driver);
			databaseConnection = DriverManager.getConnection(url, user, password);*/
			databaseConnection = ConnectionDB.getInstance().getConnection();
			
			try{
			
				
				
				
				int number =0;
				int selectedVoorstellingNr = 0;
				int aantalPlaatsen;
				boolean checkPwd = false;
				
				
				Steps stap = new Steps(scanIn);
				
				while(number != 999){
					
					selectedVoorstellingNr = 0;
					number = stap.StepGenre();
					
					
						while(selectedVoorstellingNr != 999 && number !=999){
							aantalPlaatsen=-1;
							selectedVoorstellingNr = stap.StepVoorstelling(number);
						
							while(aantalPlaatsen != 0 && selectedVoorstellingNr != 999){
								aantalPlaatsen = stap.StepVrijeplaatsen(selectedVoorstellingNr);
								
								while(!checkPwd && aantalPlaatsen !=0){
									checkPwd = stap.StepLogin();
								}
							}
						
						}
					 
				}
				
					System.out.println("Bye bye!");
				
				}
			finally{
				if(databaseConnection != null){
					try{databaseConnection.close();}catch(SQLException se){}
				}
			}
		}
		catch (SQLException sqlex1) {System.err.println(sqlex1);}
	

	}

	
	
	
}




